package com.example.system.class03;

/**
 * @Date 2022/7/18
 * @Created by Jonathan
 */
public class TestSwap {
    public static void main(String[] args) {
        int a = 16;
        int b = 600;

        System.out.println("a=" + a);
        System.out.println("b=" + b);

        System.out.println("======switch=====");
        a = a ^ b;
        b = a ^ b;
        a = a ^ b;
        System.out.println("a=" + a);
        System.out.println("b=" + b);
    }

    // i==j时会出错
    private static void swap(int[] arr, int i, int j) {
        arr[i] = arr[i] ^ arr[j];
        arr[j] = arr[i] ^ arr[j];
        arr[i] = arr[i] ^ arr[j];

    }
}
